package com.caishi.lkx.order.model;

import com.baomidou.mybatisplus.annotation.TableName;
import com.caishi.lkx.common.ienum.DeviceType;
import com.zzw.common.entity.impl.BaseIntEntity;

import com.caishi.lkx.order.ienum.status.PaymentStatus;
import com.caishi.lkx.order.ienum.type.PaymentType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author by keray
 * date:2019/7/29 11:52
 * 系统支付单
 */

@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = "系统支付单", description = "系统支付单")
@TableName("or_payment")
public class PaymentModel extends BaseIntEntity<PaymentModel> {
    /**
     * 支付类型
     */
    private PaymentType paymentType;

    /**
     * 支付状态
     */
    private PaymentStatus paymentStatus;

    /**
     * 支付订单
     */
    private String orderId;

    /**
     * 支付金额（分）
     */
    private Long paymentAmount;

    /**
     * 支付设备通道
     */
    private DeviceType deviceType;

    /**
     * 支付时间
     */
    private LocalDateTime payTime;

    /**
     * 退款时间
     */
    private LocalDateTime refundTime;

    /**
     * 支付单支付人
     */
    private String payUserId;


    /**
     * 支付模式 支付宝 微信支付模式 二维码 native
     * 激活码支付时为激活码
     */
    private String mode;
    //流水号
    private String serialNumber;

    public String getOrderSn() {
        return this.getOrderId();
    }

    public BigDecimal getPaymentAmountDecimal() {
        if (this.getPaymentAmount() == null) {
            return BigDecimal.ZERO;
        }
        return BigDecimal.valueOf(this.getPaymentAmount() / 100.0);
    }
}
